summaryrefslogtreecommitdiff
path: root/xmloff/source/text/txtstyli.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/text/txtstyli.cxx')
-rw-r--r--xmloff/source/text/txtstyli.cxx230
1 files changed, 165 insertions, 65 deletions
diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx
index 1d5e1233f2d9..89887932ec10 100644
--- a/xmloff/source/text/txtstyli.cxx
+++ b/xmloff/source/text/txtstyli.cxx
@@ -19,8 +19,6 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
@@ -35,7 +33,6 @@
#include "xmloff/xmltkmap.hxx"
#include "xmloff/xmltoken.hxx"
#include "xmloff/xmluconv.hxx"
-
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp>
@@ -43,7 +40,6 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/style/ParagraphStyleCategory.hpp>
#include <com/sun/star/style/XStyle.hpp>
-
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
@@ -53,6 +49,10 @@
#include <utility>
#include <vector>
+//UUUU
+#include <xmlsdtypes.hxx>
+#include <xmloff/xmlerror.hxx>
+
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
@@ -422,22 +422,19 @@ void XMLTextStyleContext::FillPropertySet(
// catch the combined characters attribute
// imitate XMLPropStyleContext::FillPropertySet(...)
- UniReference < SvXMLImportPropertyMapper > xImpPrMap =
- ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(GetFamily());
- DBG_ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" );
- if( xImpPrMap.is() )
- {
+ SvXMLStylesContext* pSvXMLStylesContext = static_cast< SvXMLStylesContext* >(GetStyles());
+ UniReference < SvXMLImportPropertyMapper > xImpPrMap = pSvXMLStylesContext->GetImportPropertyMapper(GetFamily());
+ DBG_ASSERT(xImpPrMap.is(),"Where is the import prop mapper?");
+ if(xImpPrMap.is())
+ {
// imitate SvXMLImportPropertyMapper::FillPropertySet(...)
-
// The reason for this is that we have no other way to
// efficiently intercept the value of combined characters. To
// get that value, we could iterate through the map once more,
// but instead we chose to insert the code into this
// iteration. I haven't been able to come up with a much more
// intelligent solution.
-
-
struct _ContextID_Index_Pair aContextIDs[] =
{
{ CTF_COMBINED_CHARACTERS_FIELD, -1 },
@@ -447,28 +444,56 @@ void XMLTextStyleContext::FillPropertySet(
{ CTF_FONTFAMILYNAME, -1 },
{ CTF_FONTFAMILYNAME_CJK, -1 },
{ CTF_FONTFAMILYNAME_CTL, -1 },
+
+ //UUU need special handling for DrawingLayer FillStyle names
+ { CTF_FILLGRADIENTNAME, -1 },
+ { CTF_FILLTRANSNAME, -1 },
+ { CTF_FILLHATCHNAME, -1 },
+ { CTF_FILLBITMAPNAME, -1 },
+
{ -1, -1 }
};
- // get property set info
- Reference< XPropertySetInfo > xInfo( rPropSet->getPropertySetInfo(), UNO_SET_THROW );
+ // the style families associated with the same index modulo 4
+ static sal_uInt16 aFamilies[] =
+ {
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_GRADIENT_ID,
+ XML_STYLE_FAMILY_SD_HATCH_ID,
+ XML_STYLE_FAMILY_SD_FILL_IMAGE_ID
+ };
+ // get property set info
+ Reference< XPropertySetInfo > xInfo;
+ UniReference< XMLPropertySetMapper > rPropMapper;
bool bAutomatic = false;
- if( ((SvXMLStylesContext *)GetStyles())->IsAutomaticStyle() &&
- ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) )
+
+ if(pSvXMLStylesContext->IsAutomaticStyle() &&
+ (XML_STYLE_FAMILY_TEXT_TEXT == GetFamily() || XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily()))
{
bAutomatic = true;
+
if( GetAutoName().getLength() )
{
OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ?
OUString( RTL_CONSTASCII_USTRINGPARAM("CharAutoStyleName") ):
OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAutoStyleName") );
+
try
{
+ if(!xInfo.is())
+ {
+ xInfo = rPropSet->getPropertySetInfo();
+ }
+
if ( xInfo->hasPropertyByName( sAutoProp ) )
+ {
rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) );
+ }
else
+ {
bAutomatic = false;
+ }
}
catch( const RuntimeException& ) { throw; }
catch( const Exception& )
@@ -478,13 +503,19 @@ void XMLTextStyleContext::FillPropertySet(
}
}
}
+
if( bAutomatic )
+ {
xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs );
+ }
else
+ {
xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
+ }
- // have we found a combined characters
sal_Int32 nIndex = aContextIDs[0].nIndex;
+
+ // have we found a combined characters
if ( nIndex != -1 )
{
Any& rAny = GetProperties()[nIndex].maValue;
@@ -497,77 +528,146 @@ void XMLTextStyleContext::FillPropertySet(
// value; if we didn't find one, we'll set to false, the file
// format default.
// border-model: same
- if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_ROW )
+ if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_ROW == GetFamily())
{
- OUString sIsSplitAllowed =
- OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSplitAllowed" ) );
- DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ),
- "property missing?" );
- rPropSet->setPropertyValue( sIsSplitAllowed,
- (aContextIDs[1].nIndex == -1)
- ? makeAny( false )
- : GetProperties()[aContextIDs[1].nIndex].maValue );
+ OUString sIsSplitAllowed = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSplitAllowed" ) );
+ DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ), "property missing?" );
+ rPropSet->setPropertyValue(
+ sIsSplitAllowed,
+ (aContextIDs[1].nIndex == -1) ? makeAny( false ) : GetProperties()[aContextIDs[1].nIndex].maValue );
}
- if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE )
+ if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_TABLE == GetFamily())
{
- OUString sCollapsingBorders(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "CollapsingBorders" ) ) );
- DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ),
- "property missing?" );
- rPropSet->setPropertyValue( sCollapsingBorders,
+ OUString sCollapsingBorders(OUString( RTL_CONSTASCII_USTRINGPARAM( "CollapsingBorders" ) ) );
+ DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ), "property missing?" );
+ rPropSet->setPropertyValue(
+ sCollapsingBorders,
(aContextIDs[2].nIndex == -1)
? makeAny( false )
: GetProperties()[aContextIDs[2].nIndex].maValue );
}
- // check for StarBats and StarMath fonts
-
- // iterate over aContextIDs entries 3..6
- for ( sal_Int32 i = 3; i < 7; i++ )
+ // iterate over aContextIDs entries, start with 3, prev ones are already used above
+ for(sal_uInt16 i(3); aContextIDs[i].nContextID != -1; i++)
{
nIndex = aContextIDs[i].nIndex;
+
if ( nIndex != -1 )
{
// Found!
struct XMLPropertyState& rState = GetProperties()[nIndex];
- Any rAny = rState.maValue;
- sal_Int32 nMapperIndex = rState.mnIndex;
-
- // Now check for font name in rState and set corrected value,
- // if necessary.
- OUString sFontName;
- rAny >>= sFontName;
- if ( sFontName.getLength() > 0 )
+
+ switch(aContextIDs[i].nContextID)
{
- OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) );
- OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) );
- if ( sFontName.equalsIgnoreAsciiCase( sStarBats ) ||
- sFontName.equalsIgnoreAsciiCase( sStarMath ) )
+ case CTF_FILLGRADIENTNAME:
+ case CTF_FILLTRANSNAME:
+ case CTF_FILLHATCHNAME:
+ case CTF_FILLBITMAPNAME:
+ {
+ // DrawingLayer FillStyle nameŽneeds to be mapped to DisplayName
+ rtl::OUString sStyleName;
+ rState.maValue >>= sStyleName;
+
+ //UUUU translate the used name from ODF intern to the name used in the Model
+ sStyleName = GetImport().GetStyleDisplayName(aFamilies[i - 7], sStyleName);
+
+ if(bAutomatic)
+ {
+ // in this case the rPropSet got not really filled since above the call to
+ // CheckSpecialContext was used and not FillPropertySet, thus the below call to
+ // setPropertyValue can fail/will not be useful (e.g. when the rPropSet
+ // is a SwXTextCursor).
+ // This happens for AutoStyles which are already filled in XMLPropStyleContext::CreateAndInsert,
+ // thus the whole mechanism based on _ContextID_Index_Pair will not work
+ // in that case. Thus the slots which need to be converted already get
+ // converted there (its called first) and not here (see
+ // translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames)
+ // For convenience, still Write back the corrected value to the XMLPropertyState entry
+ rState.maValue <<= sStyleName;
+ break;
+ }
+
+ // Still needed if it's not an AutomaticStyle (!)
+ try
+ {
+ if(!rPropMapper.is())
+ {
+ rPropMapper = xImpPrMap->getPropertySetMapper();
+ }
+
+ // set property
+ const rtl::OUString& rPropertyName = rPropMapper->GetEntryAPIName(rState.mnIndex);
+
+ if(!xInfo.is())
+ {
+ xInfo = rPropSet->getPropertySetInfo();
+ }
+
+ if(xInfo->hasPropertyByName(rPropertyName))
+ {
+ rPropSet->setPropertyValue(rPropertyName,Any(sStyleName));
+ }
+ }
+ catch(::com::sun::star::lang::IllegalArgumentException& e)
+ {
+ Sequence< rtl::OUString > aSeq(1);
+ aSeq[0] = sStyleName;
+ GetImport().SetError(XMLERROR_STYLE_PROP_VALUE | XMLERROR_FLAG_WARNING, aSeq, e.Message, NULL);
+ }
+ break;
+ }
+ default:
{
- // construct new value
- sFontName = OUString(
- RTL_CONSTASCII_USTRINGPARAM("StarSymbol") );
- Any aAny( rAny );
- aAny <<= sFontName;
-
- // get property set mapper
- UniReference<XMLPropertySetMapper> rPropMapper =
- xImpPrMap->getPropertySetMapper();
-
- // set property
- OUString rPropertyName(
- rPropMapper->GetEntryAPIName(nMapperIndex) );
- if ( xInfo->hasPropertyByName( rPropertyName ) )
+ // check for StarBats and StarMath fonts
+ Any rAny = rState.maValue;
+ sal_Int32 nMapperIndex = rState.mnIndex;
+
+ // Now check for font name in rState and set corrected value,
+ // if necessary.
+ OUString sFontName;
+ rAny >>= sFontName;
+
+ if(sFontName.getLength() > 0)
{
- rPropSet->setPropertyValue( rPropertyName, aAny );
+ OUString sStarBats(RTL_CONSTASCII_USTRINGPARAM("StarBats"));
+ OUString sStarMath(RTL_CONSTASCII_USTRINGPARAM("StarMath"));
+ if(sFontName.equalsIgnoreAsciiCase(sStarBats) ||
+ sFontName.equalsIgnoreAsciiCase(sStarMath))
+ {
+ // construct new value
+ sFontName = OUString(
+ RTL_CONSTASCII_USTRINGPARAM("StarSymbol"));
+ Any aAny(rAny);
+ aAny <<= sFontName;
+
+ if(!rPropMapper.is())
+ {
+ rPropMapper = xImpPrMap->getPropertySetMapper();
+ }
+
+ // set property
+ OUString rPropertyName(rPropMapper->GetEntryAPIName(nMapperIndex));
+
+ if(!xInfo.is())
+ {
+ xInfo = rPropSet->getPropertySetInfo();
+ }
+
+ if(xInfo->hasPropertyByName(rPropertyName))
+ {
+ rPropSet->setPropertyValue(rPropertyName,aAny);
+ }
+ }
+ // else: "normal" style name -> no correction is necessary
}
+ // else: no style name found -> illegal value -> ignore
}
- // else: "normal" style name -> no correction is necessary
}
- // else: no style name found -> illegal value -> ignore
}
}
}
}
+
+//eof