summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2002-09-27 14:12:30 +0000
committerKai Sommerfeld <kso@openoffice.org>2002-09-27 14:12:30 +0000
commit492929e862dbacd553c687872b4ff84fd5b87d78 (patch)
treef561f166f79dbb57633bb1ba726b6c0f9f79c1a5 /ucb
parente82d02a63512b31dda198a158a92ff60398f8943 (diff)
#82433# - Support for links with empty target URL.
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.cxx137
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.hxx52
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydata.cxx218
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydata.hxx38
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx18
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx6
6 files changed, 227 insertions, 242 deletions
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
index 7d8bc1016127..bf0330f9a551 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchycontent.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: obo $ $Date: 2001-09-28 07:48:54 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -242,34 +242,15 @@ HierarchyContent::HierarchyContent(
const uno::Reference< star::ucb::XContentIdentifier >& Identifier,
const star::ucb::ContentInfo& Info )
: ContentImplHelper( rxSMgr, pProvider, Identifier, sal_False ),
+ m_aProps( Info.Type.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( HIERARCHY_FOLDER_CONTENT_TYPE ) )
+ ? HierarchyEntryData::FOLDER
+ : HierarchyEntryData::LINK ),
m_eState( TRANSIENT ),
m_pProvider( pProvider ),
m_bCheckedReadOnly( false ),
m_bIsReadOnly( true )
{
- if ( Info.Type.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( HIERARCHY_FOLDER_CONTENT_TYPE ) ) )
- {
- // New folder...
- m_aProps.aContentType = Info.Type;
-// m_aProps.aTitle =
- m_aProps.bIsFolder = sal_True;
- m_aProps.bIsDocument = sal_False;
- }
- else
- {
- OSL_ENSURE(
- Info.Type.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( HIERARCHY_LINK_CONTENT_TYPE ) ),
- "HierarchyContent::HierarchyContent - Wrong content info!" );
-
- // New link...
- m_aProps.aContentType = Info.Type;
-// m_aProps.aTitle =
- m_aProps.bIsFolder = sal_False;
- m_aProps.bIsDocument = sal_True;
- }
-
setKind( Identifier );
}
@@ -425,7 +406,7 @@ HierarchyContent::getSupportedServiceNames()
rtl::OUString SAL_CALL HierarchyContent::getContentType()
throw( uno::RuntimeException )
{
- return m_aProps.aContentType;
+ return m_aProps.getContentType();
}
//=========================================================================
@@ -809,10 +790,7 @@ sal_Bool HierarchyContent::hasData(
return sal_True;
}
- HierarchyEntry aEntry( rxSMgr, pProvider, aURL );
- HierarchyEntryData aData;
-
- return aEntry.hasData();
+ return HierarchyEntry( rxSMgr, pProvider, aURL ).hasData();
}
//=========================================================================
@@ -829,36 +807,16 @@ sal_Bool HierarchyContent::loadData(
HierarchyUri aUri( aURL );
if ( aUri.isRootFolder() )
{
- // loadData must always return 'true' for root folder
- // even if no persistent data exist!!! --> Fill props!!!
-
- rProps.aContentType = rtl::OUString::createFromAscii(
- HIERARCHY_FOLDER_CONTENT_TYPE );
-// rProps.aTitle = rtl::OUString();
-// rProps.aTargetURL = rtl::OUString();
- rProps.bIsFolder = sal_True;
- rProps.bIsDocument = sal_False;
+ rProps = HierarchyContentProperties( HierarchyEntryData::FOLDER );
}
else
{
HierarchyEntry aEntry( rxSMgr, pProvider, aURL );
- if ( !aEntry.getData( rProps ) )
+ HierarchyEntryData aData;
+ if ( !aEntry.getData( aData ) )
return sal_False;
- if ( rProps.aTargetURL.getLength() > 0 )
- {
- rProps.aContentType = rtl::OUString::createFromAscii(
- HIERARCHY_LINK_CONTENT_TYPE );
- rProps.bIsFolder = sal_False;
- rProps.bIsDocument = sal_True;
- }
- else
- {
- rProps.aContentType = rtl::OUString::createFromAscii(
- HIERARCHY_FOLDER_CONTENT_TYPE );
- rProps.bIsFolder = sal_True;
- rProps.bIsDocument = sal_False;
- }
+ rProps = HierarchyContentProperties( aData );
}
return sal_True;
}
@@ -868,7 +826,7 @@ sal_Bool HierarchyContent::storeData()
{
HierarchyEntry aEntry(
m_xSMgr, m_pProvider, m_xIdentifier->getContentIdentifier() );
- return aEntry.setData( m_aProps, sal_True );
+ return aEntry.setData( m_aProps.getHierarchyEntryData(), sal_True );
}
//=========================================================================
@@ -878,7 +836,8 @@ sal_Bool HierarchyContent::renameData(
{
HierarchyEntry aEntry(
m_xSMgr, m_pProvider, xOldId->getContentIdentifier() );
- return aEntry.move( xNewId->getContentIdentifier(), m_aProps );
+ return aEntry.move( xNewId->getContentIdentifier(),
+ m_aProps.getHierarchyEntryData() );
}
//=========================================================================
@@ -893,7 +852,7 @@ sal_Bool HierarchyContent::removeData()
void HierarchyContent::setKind(
const uno::Reference< star::ucb::XContentIdentifier >& Identifier )
{
- if ( m_aProps.bIsFolder )
+ if ( m_aProps.getIsFolder() )
{
// Am I a root folder?
HierarchyUri aUri( Identifier->getContentIdentifier() );
@@ -1123,30 +1082,30 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) )
{
- xRow->appendString ( rProp, rData.aContentType );
+ xRow->appendString ( rProp, rData.getContentType() );
}
else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
{
- xRow->appendString ( rProp, rData.aTitle );
+ xRow->appendString ( rProp, rData.getTitle() );
}
else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
{
- xRow->appendBoolean( rProp, rData.bIsDocument );
+ xRow->appendBoolean( rProp, rData.getIsDocument() );
}
else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) )
{
- xRow->appendBoolean( rProp, rData.bIsFolder );
+ xRow->appendBoolean( rProp, rData.getIsFolder() );
}
else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "TargetURL" ) ) )
{
// TargetURL is only supported by links.
- if ( rData.bIsDocument )
- xRow->appendString( rProp, rData.aTargetURL );
+ if ( rData.getIsDocument() )
+ xRow->appendString( rProp, rData.getTargetURL() );
else
xRow->appendVoid( rProp );
}
@@ -1191,30 +1150,30 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
- rData.aContentType );
+ rData.getContentType() );
xRow->appendString (
beans::Property( rtl::OUString::createFromAscii( "Title" ),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
// @@@ Might actually be read-only!
beans::PropertyAttribute::BOUND ),
- rData.aTitle );
+ rData.getTitle() );
xRow->appendBoolean(
beans::Property( rtl::OUString::createFromAscii( "IsDocument" ),
-1,
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
- rData.bIsDocument );
+ rData.getIsDocument() );
xRow->appendBoolean(
beans::Property( rtl::OUString::createFromAscii( "IsFolder" ),
-1,
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
- rData.bIsFolder );
+ rData.getIsFolder() );
- if ( rData.bIsDocument )
+ if ( rData.getIsDocument() )
xRow->appendString(
beans::Property( rtl::OUString::createFromAscii( "TargetURL" ),
-1,
@@ -1222,7 +1181,7 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
static_cast< const rtl::OUString * >( 0 ) ),
// @@@ Might actually be read-only!
beans::PropertyAttribute::BOUND ),
- rData.aTargetURL );
+ rData.getTargetURL() );
// Append all Additional Core Properties.
@@ -1327,18 +1286,18 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
// No empty titles!
if ( aNewValue.getLength() > 0 )
{
- if ( aNewValue != m_aProps.aTitle )
+ if ( aNewValue != m_aProps.getTitle() )
{
// modified title -> modified URL -> exchange !
if ( m_eState == PERSISTENT )
bExchange = sal_True;
- aOldTitle = m_aProps.aTitle;
- aOldName = m_aProps.aName;
+ aOldTitle = m_aProps.getTitle();
+ aOldName = m_aProps.getName();
- m_aProps.aTitle = aNewValue;
- m_aProps.aName
- = HierarchyUri::encodeSegment( aNewValue );
+ m_aProps.setTitle( aNewValue );
+ m_aProps.setName(
+ HierarchyUri::encodeSegment( aNewValue ) );
// property change event will be set later...
@@ -1387,17 +1346,17 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
// No empty target URL's!
if ( aNewValue.getLength() > 0 )
{
- if ( aNewValue != m_aProps.aTargetURL )
+ if ( aNewValue != m_aProps.getTargetURL() )
{
aEvent.PropertyName = rValue.Name;
aEvent.OldValue
- = uno::makeAny( m_aProps.aTargetURL );
+ = uno::makeAny( m_aProps.getTargetURL() );
aEvent.NewValue
= uno::makeAny( aNewValue );
aChanges.getArray()[ nChanged ] = aEvent;
- m_aProps.aTargetURL = aNewValue;
+ m_aProps.setTargetURL( aNewValue );
nChanged++;
}
}
@@ -1488,7 +1447,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
uno::Reference< star::ucb::XContentIdentifier > xOldId
= m_xIdentifier;
uno::Reference< star::ucb::XContentIdentifier > xNewId
- = makeNewIdentifier( m_aProps.aTitle );
+ = makeNewIdentifier( m_aProps.getTitle() );
aGuard.clear();
if ( exchangeIdentity( xNewId ) )
@@ -1504,8 +1463,8 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
else
{
// Roll-back.
- m_aProps.aTitle = aOldTitle;
- m_aProps.aName = aOldName;
+ m_aProps.setTitle( aOldTitle );
+ m_aProps.setName ( aOldName );
aOldTitle = aOldName = rtl::OUString();
@@ -1520,7 +1479,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
{
aEvent.PropertyName = rtl::OUString::createFromAscii( "Title" );
aEvent.OldValue = uno::makeAny( aOldTitle );
- aEvent.NewValue = uno::makeAny( m_aProps.aTitle );
+ aEvent.NewValue = uno::makeAny( m_aProps.getTitle() );
aChanges.getArray()[ nChanged ] = aEvent;
nChanged++;
@@ -1583,7 +1542,7 @@ void HierarchyContent::insert( sal_Int32 nNameClashResolve,
}
// Check, if all required properties were set.
- if ( m_aProps.aTitle.getLength() == 0 )
+ if ( m_aProps.getTitle().getLength() == 0 )
{
uno::Sequence< rtl::OUString > aProps( 1 );
aProps[ 0 ] = rtl::OUString::createFromAscii( "Title" );
@@ -1599,7 +1558,7 @@ void HierarchyContent::insert( sal_Int32 nNameClashResolve,
// Assemble new content identifier...
uno::Reference< star::ucb::XContentIdentifier > xId
- = makeNewIdentifier( m_aProps.aTitle );
+ = makeNewIdentifier( m_aProps.getTitle() );
// Handle possible name clash...
@@ -1615,7 +1574,7 @@ void HierarchyContent::insert( sal_Int32 nNameClashResolve,
rtl::OUString(),
static_cast< cppu::OWeakObject * >( this ),
task::InteractionClassification_ERROR,
- m_aProps.aTitle ) ),
+ m_aProps.getTitle() ) ),
xEnv );
// Unreachable
}
@@ -1654,8 +1613,10 @@ void HierarchyContent::insert( sal_Int32 nNameClashResolve,
}
else
{
- m_aProps.aTitle += rtl::OUString::createFromAscii( "_" );
- m_aProps.aTitle += rtl::OUString::valueOf( nTry );
+ rtl::OUString aNewTitle( m_aProps.getTitle() );
+ aNewTitle += rtl::OUString::createFromAscii( "_" );
+ aNewTitle += rtl::OUString::valueOf( nTry );
+ m_aProps.setTitle( aNewTitle );
}
}
break;
@@ -2001,7 +1962,7 @@ void HierarchyContent::transfer(
if ( ( aChildId.lastIndexOf( '/' ) + 1 ) != aChildId.getLength() )
aChildId += rtl::OUString::createFromAscii( "/" );
- aChildId += rResult.aName;
+ aChildId += rResult.getName();
star::ucb::TransferInfo aInfo;
aInfo.MoveData = sal_False;
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.hxx b/ucb/source/ucp/hierarchy/hierarchycontent.hxx
index 4222d6b7d56d..4ec0bc66f726 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchycontent.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: kso $ $Date: 2001-07-06 09:34:20 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,9 @@
#ifndef _HIERARCHYDATA_HXX
#include "hierarchydata.hxx"
#endif
+#ifndef _HIERARCHYPROVIDER_HXX
+#include "hierarchyprovider.hxx"
+#endif
namespace com { namespace sun { namespace star { namespace beans {
struct Property;
@@ -107,14 +110,47 @@ namespace hierarchy_ucp
//=========================================================================
-struct HierarchyContentProperties : HierarchyEntryData
+class HierarchyContentProperties
{
- ::rtl::OUString aContentType; // ContentType
- sal_Bool bIsDocument; // IsDocument
- sal_Bool bIsFolder; // IsFolder
+public:
+ HierarchyContentProperties() {};
+
+ HierarchyContentProperties( const HierarchyEntryData::Type & rType )
+ : m_aData( rType ),
+ m_aContentType( rType == HierarchyEntryData::FOLDER
+ ? rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE )
+ : rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
+
+ HierarchyContentProperties( const HierarchyEntryData & rData )
+ : m_aData( rData ),
+ m_aContentType( rData.getType() == HierarchyEntryData::FOLDER
+ ? rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE )
+ : rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
+
+ const rtl::OUString & getName() const { return m_aData.getName(); }
+ void setName( const rtl::OUString & rName ) { m_aData.setName( rName ); };
+
+ const rtl::OUString & getTitle() const { return m_aData.getTitle(); }
+ void setTitle( const rtl::OUString & rTitle )
+ { m_aData.setTitle( rTitle ); };
- HierarchyContentProperties()
- : bIsDocument( sal_False ), bIsFolder( sal_True ) {}
+ const rtl::OUString & getTargetURL() const
+ { return m_aData.getTargetURL(); }
+ void setTargetURL( const rtl::OUString & rURL )
+ { m_aData.setTargetURL( rURL ); };
+
+ const rtl::OUString & getContentType() const { return m_aContentType; }
+
+ sal_Bool getIsFolder() const
+ { return m_aData.getType() == HierarchyEntryData::FOLDER; }
+
+ sal_Bool getIsDocument() const { return !getIsFolder(); }
+
+ const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
+
+private:
+ HierarchyEntryData m_aData;
+ rtl::OUString m_aContentType;
};
//=========================================================================
diff --git a/ucb/source/ucp/hierarchy/hierarchydata.cxx b/ucb/source/ucp/hierarchy/hierarchydata.cxx
index f4c98e69f631..e5e487d6687f 100644
--- a/ucb/source/ucp/hierarchy/hierarchydata.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydata.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchydata.cxx,v $
*
- * $Revision: 1.21 $
+ * $Revision: 1.22 $
*
- * last change: $Author: kso $ $Date: 2001-07-06 15:00:20 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,9 +69,6 @@
*************************************************************************/
-// Commit every single write operation vs. commit multiple write operations
-#define MULTI_COMMIT
-
#ifndef _HIERARCHYDATA_HXX
#include "hierarchydata.hxx"
#endif
@@ -100,11 +97,6 @@
#ifndef _COM_SUN_STAR_UTIL_XCHANGESBATCH_HPP_
#include <com/sun/star/util/XChangesBatch.hpp>
#endif
-#if SUPD<638
-#ifndef _COM_SUN_STAR_UTIL_XSTRINGESCAPE_HPP_
-#include <com/sun/star/util/XStringEscape.hpp>
-#endif
-#endif
#ifndef _HIERARCHYPROVIDER_HXX
#include "hierarchyprovider.hxx"
#endif
@@ -128,9 +120,6 @@ struct HierarchyEntry::iterator_Impl
{
HierarchyEntryData entry;
Reference< XHierarchicalNameAccess > dir;
-#if SUPD<638
- Reference< XStringEscape > esc;
-#endif
Sequence< OUString> names;
sal_Int32 pos;
@@ -259,9 +248,11 @@ sal_Bool HierarchyEntry::getData( HierarchyEntryData& rData )
if ( !xRootReadAccess->hasByHierarchicalName( aTitlePath ) )
return sal_False;
+ OUString aValue;
+
// Get Title value.
if ( !( xRootReadAccess->getByHierarchicalName(
- aTitlePath ) >>= rData.aTitle ) )
+ aTitlePath ) >>= aValue ) )
{
OSL_ENSURE( sal_False,
"HierarchyEntry::getData - "
@@ -269,11 +260,13 @@ sal_Bool HierarchyEntry::getData( HierarchyEntryData& rData )
return sal_False;
}
+ rData.setTitle( aValue );
+
// Get TargetURL value.
OUString aTargetURLPath = m_aPath;
aTargetURLPath += OUString::createFromAscii( "/TargetURL" );
if ( !( xRootReadAccess->getByHierarchicalName(
- aTargetURLPath ) >>= rData.aTargetURL ) )
+ aTargetURLPath ) >>= aValue ) )
{
OSL_ENSURE( sal_False,
"HierarchyEntry::getData - "
@@ -281,15 +274,48 @@ sal_Bool HierarchyEntry::getData( HierarchyEntryData& rData )
return sal_False;
}
- rData.aName = m_aName;
+ rData.setTargetURL( aValue );
+
+ OUString aTypePath = m_aPath;
+ aTypePath += OUString::createFromAscii( "/Type" );
+ if ( xRootReadAccess->hasByHierarchicalName( aTypePath ) )
+ {
+ // Might not be present since it was introduced long after
+ // Title and TargetURL (#82433#)... So not getting it is
+ // not an error.
+
+ // Get Type value.
+ sal_Int32 nType = 0;
+ if ( xRootReadAccess->getByHierarchicalName( aTypePath )
+ >>= nType )
+ {
+ if ( nType == 0 )
+ {
+ rData.setType( HierarchyEntryData::LINK );
+ }
+ else if ( nType == 1 )
+ {
+ rData.setType( HierarchyEntryData::FOLDER );
+ }
+ else
+ {
+ OSL_ENSURE( sal_False,
+ "HierarchyEntry::getData - "
+ "Unknown Type value!" );
+ return sal_False;
+ }
+ }
+ }
+
+ rData.setName( m_aName );
return sal_True;
}
}
- catch ( RuntimeException& )
+ catch ( RuntimeException const & )
{
throw;
}
- catch ( NoSuchElementException& )
+ catch ( NoSuchElementException const & )
{
// getByHierarchicalName
@@ -452,12 +478,19 @@ sal_Bool HierarchyEntry::setData(
// Set Title value.
xNameReplace->replaceByName(
OUString::createFromAscii( "Title" ),
- makeAny( rData.aTitle ) );
+ makeAny( rData.getTitle() ) );
// Set TargetURL value.
xNameReplace->replaceByName(
OUString::createFromAscii( "TargetURL" ),
- makeAny( rData.aTargetURL ) );
+ makeAny( rData.getTargetURL() ) );
+
+ // Set Type value.
+ sal_Int32 nType
+ = rData.getType() == HierarchyEntryData::LINK ? 0 : 1;
+ xNameReplace->replaceByName(
+ OUString::createFromAscii( "Type" ),
+ makeAny( nType ) );
if ( xContainer.is() )
xContainer->insertByName(
@@ -764,10 +797,14 @@ sal_Bool HierarchyEntry::move(
xNewNameReplace->replaceByName(
OUString::createFromAscii( "Title" ),
- makeAny( rData.aTitle ) );
+ makeAny( rData.getTitle() ) );
xNewNameReplace->replaceByName(
OUString::createFromAscii( "TargetURL" ),
- makeAny( rData.aTargetURL ) );
+ makeAny( rData.getTargetURL() ) );
+ sal_Int32 nType = rData.getType() == HierarchyEntryData::LINK ? 0 : 1;
+ xNewNameReplace->replaceByName(
+ OUString::createFromAscii( "Type" ),
+ makeAny( nType ) );
xNewNameContainer->insertByName( aNewKey, aEntry );
xNewParentBatch->commitChanges();
@@ -992,12 +1029,6 @@ sal_Bool HierarchyEntry::first( iterator& it )
"HierarchyEntry::first - No hier. name access!" );
it.m_pImpl->dir = xHierNameAccess;
-
-#if SUPD<638
- Reference< XStringEscape > xEscaper(
- xRootHierNameAccess, UNO_QUERY );
- it.m_pImpl->esc = xEscaper;
-#endif
}
}
catch ( RuntimeException& )
@@ -1041,61 +1072,6 @@ sal_Bool HierarchyEntry::next( iterator& it )
//=========================================================================
OUString HierarchyEntry::createPathFromHierarchyURL( const HierarchyUri& rURI )
{
-#if SUPD<638
- Reference< XStringEscape > xEscaper( getRootReadAccess(), UNO_QUERY );
-
-// OSL_ENSURE( xEscaper.is(),
-// "HierarchyEntry::createPathFromHierarchyURL - No escaper!" );
-
- // Transform path....
- // folder/subfolder/subsubfolder
- // --> folder/Children/subfolder/Children/subsubfolder
-
- OUString aPath = rURI.getPath().copy( 1 ); // skip leading slash.
- sal_Int32 nLen = aPath.getLength();
-
- OUString aNewPath;
- if ( nLen )
- {
- const OUString aChildren = OUString::createFromAscii( "/Children/" );
- sal_Int32 nStart = 0;
- sal_Int32 nEnd = aPath.indexOf( '/' );
-
- do
- {
- if ( nEnd == -1 )
- nEnd = nLen;
-
- OUString aToken = aPath.copy( nStart, nEnd - nStart );
-
- if ( xEscaper.is() )
- {
- try
- {
- aToken = xEscaper->escapeString( aToken );
- }
- catch ( IllegalArgumentException& )
- {
- OSL_ENSURE( sal_False,
- "HierarchyEntry::createPathFromHierarchyURL - "
- "caught IllegalArgumentException!" );
- }
- }
-
- aNewPath += aToken;
-
- if ( nEnd != nLen )
- {
- aNewPath += aChildren;
- nStart = nEnd + 1;
- nEnd = aPath.indexOf( '/', nStart );
- }
- }
- while ( nEnd != nLen );
- }
-
- return aNewPath;
-#else
// Transform path....
// folder/subfolder/subsubfolder
// --> ['folder']/Children/['subfolder']/Children/['subsubfolder']
@@ -1134,7 +1110,6 @@ OUString HierarchyEntry::createPathFromHierarchyURL( const HierarchyUri& rURI )
}
return aPath;
-#endif
}
//=========================================================================
@@ -1227,35 +1202,6 @@ const HierarchyEntryData& HierarchyEntry::iterator::operator*() const
{
try
{
-#if SUPD<638
- OUString aKey = m_pImpl->names.getConstArray()[ m_pImpl->pos ];
- OUString aTitle = aKey;
- OUString aTargetURL = aKey;
- aTitle += OUString::createFromAscii( "/Title" );
- aTargetURL += OUString::createFromAscii( "/TargetURL" );
-
- m_pImpl->dir->getByHierarchicalName( aTitle )
- >>= m_pImpl->entry.aTitle;
- m_pImpl->dir->getByHierarchicalName( aTargetURL )
- >>= m_pImpl->entry.aTargetURL;
-
- // key may be encoded!
- if ( m_pImpl->esc.is() )
- {
- try
- {
- aKey = m_pImpl->esc->unescapeString( aKey );
- }
- catch ( IllegalArgumentException& )
- {
- }
- catch ( Exception& )
- {
- }
- }
-
- m_pImpl->entry.aName = aKey;
-#else
rtl::OUStringBuffer aKey;
aKey.appendAscii( "['" );
makeXMLName( m_pImpl->names.getConstArray()[ m_pImpl->pos ], aKey );
@@ -1263,20 +1209,50 @@ const HierarchyEntryData& HierarchyEntry::iterator::operator*() const
rtl::OUString aTitle = aKey.makeStringAndClear();
rtl::OUString aTargetURL = aTitle;
+ rtl::OUString aType = aTitle;
aTitle += OUString::createFromAscii( "/Title" );
aTargetURL += OUString::createFromAscii( "/TargetURL" );
+ aType += OUString::createFromAscii( "/Type" );
- m_pImpl->dir->getByHierarchicalName( aTitle )
- >>= m_pImpl->entry.aTitle;
- m_pImpl->dir->getByHierarchicalName( aTargetURL )
- >>= m_pImpl->entry.aTargetURL;
+ OUString aValue;
+ m_pImpl->dir->getByHierarchicalName( aTitle ) >>= aValue;
+ m_pImpl->entry.setTitle( aValue );
- m_pImpl->entry.aName
- = m_pImpl->names.getConstArray()[ m_pImpl->pos ];
-#endif
+ m_pImpl->dir->getByHierarchicalName( aTargetURL ) >>= aValue;
+ m_pImpl->entry.setTargetURL( aValue );
+
+ if ( m_pImpl->dir->hasByHierarchicalName( aType ) )
+ {
+ // Might not be present since it was introduced long
+ // after Title and TargetURL (#82433#)... So not getting
+ // it is not an error.
+
+ // Get Type value.
+ sal_Int32 nType = 0;
+ if ( m_pImpl->dir->getByHierarchicalName( aType ) >>= nType )
+ {
+ if ( nType == 0 )
+ {
+ m_pImpl->entry.setType( HierarchyEntryData::LINK );
+ }
+ else if ( nType == 1 )
+ {
+ m_pImpl->entry.setType( HierarchyEntryData::FOLDER );
+ }
+ else
+ {
+ OSL_ENSURE( sal_False,
+ "HierarchyEntry::getData - "
+ "Unknown Type value!" );
+ }
+ }
+ }
+
+ m_pImpl->entry.setName(
+ m_pImpl->names.getConstArray()[ m_pImpl->pos ] );
}
- catch ( NoSuchElementException& )
+ catch ( NoSuchElementException const & )
{
m_pImpl->entry = HierarchyEntryData();
}
diff --git a/ucb/source/ucp/hierarchy/hierarchydata.hxx b/ucb/source/ucp/hierarchy/hierarchydata.hxx
index 12c5bd6846a7..7d05d4680210 100644
--- a/ucb/source/ucp/hierarchy/hierarchydata.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydata.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchydata.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: kso $ $Date: 2001-07-04 09:08:28 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,17 +81,35 @@ namespace hierarchy_ucp
//=========================================================================
-struct HierarchyEntryData
+class HierarchyEntryData
{
- ::rtl::OUString aName; // language independent name of the entry
+public:
+ enum Type { NONE, LINK, FOLDER };
+
+ HierarchyEntryData() : m_aType( NONE ) {}
+ HierarchyEntryData( const Type & rType ) : m_aType( rType ) {}
+
+ const rtl::OUString & getName() const { return m_aName; }
+ void setName( const rtl::OUString & rName ) { m_aName = rName; }
- ::rtl::OUString aTitle; // Title (language dependent)
- ::rtl::OUString aTargetURL; // Target URL ( links only )
+ const rtl::OUString & getTitle() const { return m_aTitle; }
+ void setTitle( const rtl::OUString & rTitle ) { m_aTitle = rTitle; }
- HierarchyEntryData() {}
- HierarchyEntryData( const ::rtl::OUString& rTitle,
- const ::rtl::OUString& rTargetURL )
- : aTitle( rTitle ), aTargetURL( rTargetURL ) {}
+ const rtl::OUString & getTargetURL() const { return m_aTargetURL; }
+ void setTargetURL( const rtl::OUString & rURL ) { m_aTargetURL = rURL; }
+
+ Type getType() const
+ { return ( m_aType != NONE ) ? m_aType
+ : m_aTargetURL.getLength()
+ ? LINK
+ : FOLDER; }
+ void setType( const Type & rType ) { m_aType = rType; }
+
+private:
+ rtl::OUString m_aName; // Name (language independent)
+ rtl::OUString m_aTitle; // Title (language dependent)
+ rtl::OUString m_aTargetURL; // Target URL ( links only )
+ Type m_aType; // Type
};
//=========================================================================
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
index ee576cab973f..f6a41d69e05b 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchydatasupplier.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: kso $ $Date: 2001-06-25 09:08:40 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -205,7 +205,7 @@ rtl::OUString HierarchyResultSetDataSupplier::queryContentIdentifierString(
if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
aId += rtl::OUString::createFromAscii( "/" );
- aId += m_pImpl->m_aResults[ nIndex ]->aData.aName;
+ aId += m_pImpl->m_aResults[ nIndex ]->aData.getName();
m_pImpl->m_aResults[ nIndex ]->aId = aId;
return aId;
@@ -413,13 +413,7 @@ HierarchyResultSetDataSupplier::queryPropertyValues( sal_uInt32 nIndex )
static rtl::OUString aLinkType(
rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ) );
- HierarchyContentProperties aData;
-
- aData.aTitle = m_pImpl->m_aResults[ nIndex ]->aData.aTitle;
- aData.aTargetURL = m_pImpl->m_aResults[ nIndex ]->aData.aTargetURL;
- aData.bIsDocument = ( aData.aTargetURL.getLength() > 0 );
- aData.bIsFolder = !aData.bIsDocument;
- aData.aContentType = aData.bIsFolder ? aFolderType : aLinkType;
+ HierarchyContentProperties aData( m_pImpl->m_aResults[ nIndex ]->aData );
uno::Reference< sdbc::XRow > xRow = HierarchyContent::getPropertyValues(
m_pImpl->m_xSMgr,
@@ -465,7 +459,7 @@ sal_Bool HierarchyResultSetDataSupplier::checkResult(
switch ( m_pImpl->m_nOpenMode )
{
case star::ucb::OpenMode::FOLDERS:
- if ( rResult.aTargetURL.getLength() > 0 )
+ if ( rResult.getType() == HierarchyEntryData::LINK )
{
// Entry is a link.
return sal_False;
@@ -473,7 +467,7 @@ sal_Bool HierarchyResultSetDataSupplier::checkResult(
break;
case star::ucb::OpenMode::DOCUMENTS:
- if ( rResult.aTargetURL.getLength() == 0 )
+ if ( rResult.getType() == HierarchyEntryData::FOLDER )
{
// Entry is a folder.
return sal_False;
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx b/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx
index 3abf9f35cba0..2a3734d0e716 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hierarchydatasupplier.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: kso $ $Date: 2001-06-25 09:08:40 $
+ * last change: $Author: kso $ $Date: 2002-09-27 15:12:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,7 +76,7 @@
namespace hierarchy_ucp {
-struct HierarchyEntryData;
+class HierarchyEntryData;
struct DataSupplier_Impl;
class HierarchyContent;