Propiedades Efectivas de Forma
En este tema, discutiremos propiedades efectivas y locales. Cuando establecemos valores directamente en estos niveles
- En propiedades de porción en la diapositiva de la porción.
- En estilo de texto de forma prototipo en la diapositiva de diseño o de maestra (si la forma del marco de texto de la porción tiene uno).
- En la configuración global de texto de la presentación.
entonces esos valores se llaman valores locales. En cualquier nivel, los valores locales pueden ser definidos u omitidos. Pero finalmente, cuando llega el momento en que la aplicación necesita saber cómo debe verse la porción, utiliza los valores efectivos. Puedes obtener valores efectivos utilizando el método GetEffective() del formato local.
El siguiente ejemplo muestra cómo obtener valores efectivos.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)); | |
System::SharedPtr<ITextFrameFormat> localTextFrameFormat = shape->get_TextFrame()->get_TextFrameFormat(); | |
System::SharedPtr<ITextFrameFormatEffectiveData> effectiveTextFrameFormat = localTextFrameFormat->GetEffective(); | |
System::SharedPtr<IPortionFormat> localPortionFormat = shape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat(); | |
System::SharedPtr<IPortionFormatEffectiveData> effectivePortionFormat = localPortionFormat->GetEffective(); | |
Obtener Propiedades Efectivas de la Cámara
Aspose.Slides para C++ permite a los desarrolladores obtener las propiedades efectivas de la cámara. Para este propósito, se ha añadido la clase CameraEffectiveData en Aspose.Slides. La clase CameraEffectiveData representa un objeto inmutable que contiene las propiedades efectivas de la cámara. Una instancia de la clase CameraEffectiveData se utiliza como parte de la clase ThreeDFormatEffectiveData, que es un par de valores efectivos para la clase ThreeDFormat.
El siguiente fragmento de código muestra cómo obtener propiedades efectivas para la cámara.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective(); | |
System::Console::WriteLine(u"= Effective camera properties ="); | |
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_Camera()->get_CameraType())); | |
System::Console::WriteLine(System::String(u"Field of view: ") + threeDEffectiveData->get_Camera()->get_FieldOfViewAngle()); | |
System::Console::WriteLine(System::String(u"Zoom: ") + threeDEffectiveData->get_Camera()->get_Zoom()); | |
Obtener Propiedades Efectivas del Ligero Rig
Aspose.Slides para C++ permite a los desarrolladores obtener las propiedades efectivas del Ligero Rig. Para este propósito, se ha añadido la clase LightRigEffectiveData en Aspose.Slides. La clase LightRigEffectiveData representa un objeto inmutable que contiene las propiedades efectivas del ligero rig. Una instancia de la clase LightRigEffectiveData se utiliza como parte de la clase ThreeDFormatEffectiveData, que es un par de valores efectivos para la clase ThreeDFormat.
El siguiente fragmento de código muestra cómo obtener propiedades efectivas para el Ligero Rig.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective(); | |
System::Console::WriteLine(u"= Effective light rig properties ="); | |
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_LightRig()->get_LightType())); | |
System::Console::WriteLine(System::String(u"Direction: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_LightRig()->get_Direction())); | |
Obtener Propiedades Efectivas de la Forma Bevel
Aspose.Slides para C++ permite a los desarrolladores obtener las propiedades efectivas de la Forma Bevel. Para este propósito, se ha añadido la clase ShapeBevelEffectiveData en Aspose.Slides. La clase ShapeBevelEffectiveData representa un objeto inmutable que contiene las propiedades de relieve de la cara de la forma efectiva. Una instancia de la clase ShapeBevelEffectiveData se utiliza como parte de la clase ThreeDFormatEffectiveData, que es un par de valores efectivos para la clase ThreeDFormat.
El siguiente fragmento de código muestra cómo obtener propiedades efectivas para la Forma Bevel.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective(); | |
System::Console::WriteLine(u"= Effective shape's top face relief properties ="); | |
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_BevelTop()->get_BevelType())); | |
System::Console::WriteLine(System::String(u"Width: ") + threeDEffectiveData->get_BevelTop()->get_Width()); | |
System::Console::WriteLine(System::String(u"Height: ") + threeDEffectiveData->get_BevelTop()->get_Height()); | |
Obtener Propiedades Efectivas del Marco de Texto
Usando Aspose.Slides para C++, puedes obtener propiedades efectivas del Marco de Texto. Para este propósito, se ha añadido la clase TextFrameFormatEffectiveData en Aspose.Slides, que contiene propiedades efectivas de formato del marco de texto.
El siguiente fragmento de código muestra cómo obtener propiedades efectivas de formato del marco de texto.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)); | |
System::SharedPtr<ITextFrameFormatEffectiveData> effectiveTextFrameFormat = shape->get_TextFrame()->get_TextFrameFormat()->GetEffective(); | |
System::Console::WriteLine(System::String(u"Anchoring type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_AnchoringType())); | |
System::Console::WriteLine(System::String(u"Autofit type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_AutofitType())); | |
System::Console::WriteLine(System::String(u"Text vertical type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_TextVerticalType())); | |
System::Console::WriteLine(u"Margins"); | |
System::Console::WriteLine(System::String(u" Left: ") + effectiveTextFrameFormat->get_MarginLeft()); | |
System::Console::WriteLine(System::String(u" Top: ") + effectiveTextFrameFormat->get_MarginTop()); | |
System::Console::WriteLine(System::String(u" Right: ") + effectiveTextFrameFormat->get_MarginRight()); | |
System::Console::WriteLine(System::String(u" Bottom: ") + effectiveTextFrameFormat->get_MarginBottom()); | |
Obtener Propiedades Efectivas del Estilo de Texto
Usando Aspose.Slides para C++, puedes obtener propiedades efectivas del Estilo de Texto. Para este propósito, se ha añadido la clase TextStyleEffectiveData en Aspose.Slides, que contiene propiedades efectivas del estilo de texto.
El siguiente fragmento de código muestra cómo obtener propiedades efectivas del estilo de texto.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)); | |
System::SharedPtr<ITextStyleEffectiveData> effectiveTextStyle = shape->get_TextFrame()->get_TextFrameFormat()->get_TextStyle()->GetEffective(); | |
for (int32_t i = 0; i <= 8; i++) | |
{ | |
System::SharedPtr<IParagraphFormatEffectiveData> effectiveStyleLevel = effectiveTextStyle->GetLevel(i); | |
System::Console::WriteLine(System::String(u"= Effective paragraph formatting for style level #") + i + u" ="); | |
System::Console::WriteLine(System::String(u"Depth: ") + effectiveStyleLevel->get_Depth()); | |
System::Console::WriteLine(System::String(u"Indent: ") + effectiveStyleLevel->get_Indent()); | |
System::Console::WriteLine(System::String(u"Alignment: ") + System::ObjectExt::ToString(effectiveStyleLevel->get_Alignment())); | |
System::Console::WriteLine(System::String(u"Font alignment: ") + System::ObjectExt::ToString(effectiveStyleLevel->get_FontAlignment())); | |
} | |
Obtener Valor Efectivo de Altura de Fuente
Usando Aspose.Slides para C++, puedes obtener propiedades efectivas de la Altura de Fuente. Aquí está el código que demuestra el cambio del valor efectivo de altura de fuente de la porción después de establecer valores locales de altura de fuente en diferentes niveles de estructura de presentación.
// The path to the documents directory. | |
const String outPath = u"../out/SetLocalFontHeightValues.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(); | |
System::SharedPtr<IAutoShape> newShape = pres->get_Slides()->idx_get(0)->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Rectangle, 100.0f, 100.0f, 400.0f, 75.0f, false); | |
newShape->AddTextFrame(u""); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->Clear(); | |
System::SharedPtr<IPortion> portion0 = System::MakeObject<Portion>(u"Sample text with first portion"); | |
System::SharedPtr<IPortion> portion1 = System::MakeObject<Portion>(u" and second portion."); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->Add(portion0); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->Add(portion1); | |
System::Console::WriteLine(u"Effective font height just after creation:"); | |
System::Console::WriteLine(System::String(u"Portion #0: ") + portion0->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
System::Console::WriteLine(System::String(u"Portion #1: ") + portion1->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
pres->get_DefaultTextStyle()->GetLevel(0)->get_DefaultPortionFormat()->set_FontHeight(24.0f); | |
System::Console::WriteLine(u"Effective font height after setting entire presentation default font height:"); | |
System::Console::WriteLine(System::String(u"Portion #0: ") + portion0->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
System::Console::WriteLine(System::String(u"Portion #1: ") + portion1->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_ParagraphFormat()->get_DefaultPortionFormat()->set_FontHeight(40.0f); | |
System::Console::WriteLine(u"Effective font height after setting paragraph default font height:"); | |
System::Console::WriteLine(System::String(u"Portion #0: ") + portion0->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
System::Console::WriteLine(System::String(u"Portion #1: ") + portion1->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat()->set_FontHeight(55.0f); | |
System::Console::WriteLine(u"Effective font height after setting portion #0 font height:"); | |
System::Console::WriteLine(System::String(u"Portion #0: ") + portion0->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
System::Console::WriteLine(System::String(u"Portion #1: ") + portion1->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
newShape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(1)->get_PortionFormat()->set_FontHeight(18.0f); | |
System::Console::WriteLine(u"Effective font height after setting portion #1 font height:"); | |
System::Console::WriteLine(System::String(u"Portion #0: ") + portion0->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
System::Console::WriteLine(System::String(u"Portion #1: ") + portion1->get_PortionFormat()->GetEffective()->get_FontHeight()); | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); |
Obtener Formato de Relleno Efectivo para Tabla
Usando Aspose.Slides para C++, puedes obtener formateo de relleno efectivo para diferentes partes lógicas de la tabla. Para este propósito, se ha añadido la interfaz IFillFormatEffectiveData en Aspose.Slides, que contiene propiedades de formateo de relleno efectivo. Ten en cuenta que el formato de celda siempre tiene mayor prioridad que el formato de fila, una fila tiene mayor prioridad que la columna y la columna tiene mayor prioridad que toda la tabla.
Así que, finalmente, las propiedades de CellFormatEffectiveData se utilizan siempre para dibujar la tabla. El siguiente fragmento de código muestra cómo obtener formateo de relleno efectivo para diferentes partes lógicas de la tabla.
// The path to the documents directory. | |
const String templatePath = u"../templates/Presentation1.pptx"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath); | |
System::SharedPtr<ITable> tbl = System::DynamicCast_noexcept<Aspose::Slides::ITable>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)); | |
System::SharedPtr<ITableFormatEffectiveData> tableFormatEffective = tbl->get_TableFormat()->GetEffective(); | |
System::SharedPtr<IRowFormatEffectiveData> rowFormatEffective = tbl->get_Rows()->idx_get(0)->get_RowFormat()->GetEffective(); | |
System::SharedPtr<IColumnFormatEffectiveData> columnFormatEffective = tbl->get_Columns()->idx_get(0)->get_ColumnFormat()->GetEffective(); | |
System::SharedPtr<ICellFormatEffectiveData> cellFormatEffective = tbl->idx_get(0, 0)->get_CellFormat()->GetEffective(); | |
System::SharedPtr<IFillFormatEffectiveData> tableFillFormatEffective = tableFormatEffective->get_FillFormat(); | |
System::SharedPtr<IFillFormatEffectiveData> rowFillFormatEffective = rowFormatEffective->get_FillFormat(); | |
System::SharedPtr<IFillFormatEffectiveData> columnFillFormatEffective = columnFormatEffective->get_FillFormat(); | |
System::SharedPtr<IFillFormatEffectiveData> cellFillFormatEffective = cellFormatEffective->get_FillFormat(); | |